<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>16题判断奇偶性</title>
    <script>
        function caculate(flag) {
            var num1 = prompt(flag ? '请输入正确的数' : '请输入第一个数');
            if (!/^[0-9]*$/i.test(num1)) {
                caculate(true);
                return;
            }
            var num2 = prompt(flag ? '请输入正确的数' : '请输入第二个数');
            if (!/^[0-9]*$/i.test(num2)) {
                caculate(true);
                return;
            }
            
            let rs1 = num1 % 2;
            let rs2 = num2 % 2;
            if (rs1 === rs2) {
                alert(`您好，${num1}和${num2}的奇偶性相同`);
            } else {
                alert(`您好，${num1}和${num2}的奇偶性不同`);
            }
        }
    </script>
</head>
<body>
    <p>
        点击按钮开始输入<input type="button" value="点击输入" onclick="caculate()">
    </p>
</body>
</html>